package com.yitiao.data_algorithms.leetcode.editor.cn;

import com.yitiao.data_algorithms.leetcode.editor.cn.base.ListNode;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.TreeNode;

class HeWeiSdeLiangGeShuZiLcof {
    // 2022-08-22 18:44:34
    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int[] twoSum(int[] nums, int target) {
            int head = 0, tail = nums.length - 1;
            while (head < tail) {
                if (nums[head] + nums[tail] == target) {
                    return new int[]{nums[head], nums[tail]};
                } else if (nums[head] + nums[tail] > target) {
                    tail--;
                } else {
                    head++;
                }
            }
            return new int[2];
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}